package ducna.misscall.screen.misscall;

import java.util.ArrayList;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import ducna.alozo.misscall.R;
import ducna.misscall.common.model.DetailMissCall;
import ducna.misscall.comon.fragment.BaseFragment;
import ducna.misscall.screen.misscall.adapter.ListDetailMissCallAdapter;
import ducna.misscall.utils.Logger;

/**
 * @author NGUYENANHDUC
 */
public class DetailMissCallFragment extends BaseFragment implements OnClickListener{
	private String TAG = DetailMissCallFragment.class.getSimpleName();

	private ListView mListViewMissCall;
	private ListDetailMissCallAdapter mAdapter;
	
	private TextView mTextViewTitle;
	private ImageView mImageViewBack;
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.fragment_detail_miss_call, container, false);
		//		title
		mTextViewTitle = (TextView) view.findViewById(R.id.textViewTitle);
		mTextViewTitle.setText(getString(R.string.header_information));
		// icon back
		mImageViewBack = (ImageView) view.findViewById(R.id.imageViewBack);
		mImageViewBack.setOnClickListener(this);
		mListViewMissCall = (ListView) view.findViewById(R.id.listViewDetailMissCall);
		mAdapter = new ListDetailMissCallAdapter(getActivity());
		mAdapter.setArrayMissCall(createSimpleData());
		mListViewMissCall.setAdapter(mAdapter);
		return view;
	}
	
	public ArrayList<DetailMissCall> createSimpleData(){
		ArrayList<DetailMissCall> data = new ArrayList<DetailMissCall>();
		
		for (int i = 0; i < 20; i++) {
			DetailMissCall detail = new DetailMissCall();
			detail.setDate("15/12/2014");
			detail.setTime("12:12");
			data.add(detail);
		}
		Logger.out(TAG , "data size : " + data.size());
		return data;
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		if (v == mImageViewBack) {
			getActivity().getSupportFragmentManager().beginTransaction().remove(this).commit();
		}
	}
}
